﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ace_pso
{
    /// <summary>
    /// 负责数据在数据库中的读写
    /// </summary>
    public class DataGateWay
    {
        public static void InsertGBest(int id, double profit, double risk)
        {
            Database db = DatabaseFactory.CreateDatabase();
            string sqlString = string.Format("Insert INTO GBest (id,profit,risk) VALUES ({0},{1},{2})", id, profit, risk);
            db.ExecuteNonQuery(CommandType.Text, sqlString);
        }

        public static void InsertPBest(double profit, double risk)
        {
            Database db = DatabaseFactory.CreateDatabase();
            string sqlString = string.Format("Insert INTO PBest (profit,risk) VALUES ({0},{1})", profit, risk);
            db.ExecuteNonQuery(CommandType.Text, sqlString);
        }

        public static void InsertEnumAll(string z, double profit, double risk)
        {
            Database db = DatabaseFactory.CreateDatabase();
            string sqlString = string.Format("Insert INTO EnumAll (z,profit,risk) VALUES ({0},{1},{2})", z, profit, risk);
            db.ExecuteNonQuery(CommandType.Text, sqlString);
        }
    }
}
